use std::ffi::c_char;

use crate::{c_char_x::CChar, JsEngine};

pub type ExtendCRequestString = *const c_char;
pub type ExtendCResponseString = *mut c_char;

#[no_mangle]
pub extern "C" fn eval(script: ExtendCRequestString) -> ExtendCResponseString {
    let script = CChar::to_string(script);

    let mut js_engine = JsEngine::default();
    let result = js_engine.eval(script);

    CChar::to_response_string(result.to_string())
}

#[no_mangle]
pub extern "C" fn add(a: usize, b: usize) -> usize {
    a + b
}
